package com.example.controller;

import com.example.entity.ProductType;
import com.example.entity.Result;
import com.example.service.ProductTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author:tjf
 * @Description:
 */
@RequestMapping("/productCategory")
@RestController
public class ProductTypeController {
    @Autowired
    private ProductTypeService productTypeService;

    /**
     * 查询商品分类树接口url/productCategory/product-category-tree
     * @return
     */
    @RequestMapping("/product-category-tree")
    public Result getProductTypeTree(){
        // 执行获取商品分类树的业务方法
        List<ProductType> productTypeTree = productTypeService.allProductTypeToTree();

        // 响应
        return Result.ok(productTypeTree);
    }

    /**
     * 验证商品分类编码的接口url/productCategory/verify-type-code
     * @param typeCode
     * @return
     */
    @RequestMapping("/verify-type-code")
    public Result verifyProductTypeCode(String typeCode){
        // 执行验证商品分类编码是否重复的业务方法
        Result result = productTypeService.verifyProductTypeCode(typeCode);

        // 响应
        return result;
    }
}
